<template>
	<view>
		<view class="registerTitle">
			<view :class="{'active':isRegistActive==1}" @click="registActive(1)">基本信息</view>
			<view :class="{'active':isRegistActive==2}" @click="registActive(2)">收货地址</view>
			<view :class="{'active':isRegistActive==3}" @click="registActive(3)">可购商品</view>
		</view>
		<view v-if="isRegistActive==1">
			<view class='addAddress'>
				<view class='list'>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>顾客资格</view>
						<picker :value="registInfo.member.lastJoinLevelIndex"
							v-model="registInfo.member.lastJoinLevelIndex" name="rechargeWay" mode='selector'
							:range="rechargeMode" @change="bindPickerChange_glzg" range-key='name'>
							<view class="uni-input pickerView" v-if="registInfo.member.lastJoinLevelIndex!==''">
								{{rechargeMode[registInfo.member.lastJoinLevelIndex].name}}
							</view>
							<view v-else style="color:#ccc;">
								请选择顾客资格
							</view>
						</picker>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>登录用户名</view>
						<input type='text' placeholder='请输入登录用户名' @blur="memberCodeBlur"
							v-model="registInfo.member.memberCode" placeholder-class='placeholder'></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>登录密码</view>
						<input type='text' placeholder='初始支付密码与登录密码一致,请及时修改' @blur="passwordBlur"
							v-model="registInfo.member.password" placeholder-class='placeholder'></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>顾客姓名</view>
						<input placeholder='姓名必须与银行账户保持一致' v-model='registInfo.member.realName'
							placeholder-class='placeholder'></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>手机号</view>
						<input placeholder='请输入手机号' @blur="mobileBlur" pattern="\d*" v-model='registInfo.member.mobile'
							placeholder-class='placeholder'></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>证件号码</view>
						<input placeholder='请输入证件号码' v-model='registInfo.member.idCard' placeholder-class='placeholder'
							@blur="idCardBlur"></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text class="requiredBox">*</text>性别</view>
						<picker :value="registInfo.member.genderIndex" v-model="registInfo.member.genderIndex"
							name="rechargeWay" mode='selector' :range="genderList" @change="bindPickerChange_gender"
							range-key='name'>
							<view class="uni-input pickerView" v-if="registInfo.member.genderIndex!==null">
								{{genderList[registInfo.member.genderIndex].name}}
							</view>
							<view v-else style="color:#ccc;">
								请选择性别
							</view>
						</picker>
					</view>
					<view class='item acea-row row-between-wrapper' style="position: relative;">
						<view class='name'><text class="requiredBox">*</text>分享编号</view>
						<input placeholder='分享编号' @blur="introducerCodeBulr" v-model='registInfo.member.introducerCode'
							placeholder-class='placeholder'></input>
						<view class="codeDetail">
							{{introducerCode_name}}
						</view>
					</view>
					<view class='item acea-row row-between-wrapper' v-if="!firstIntro">
						<view class='name'><text class="requiredBox">*</text>AB区最底层编号</view>
						<picker :value="registInfo.member.parentCodeIndex" v-model="registInfo.member.parentCodeIndex"
							name="rechargeWay" mode='selector' :range="AB_last_code"
							@change="bindPickerChange_parentCode" range-key='label'>
							<view class="uni-input pickerView" v-if="registInfo.member.parentCodeIndex!==null">
								{{AB_last_code[registInfo.member.parentCodeIndex].label}}
							</view>
							<view v-else style="color:#ccc;">
								请选择最底层编号
							</view>
						</picker>
					</view>
					<view class='item acea-row row-between-wrapper' style="position:relative">
						<view class='name'><text class="requiredBox">*</text>服务编号</view>
						<input placeholder='服务编号' @blur="parentCodeBlur" :disabled="isFirstIntro" v-model='registInfo.member.parentCode'
							placeholder-class='placeholder'></input>
						<view class="codeDetail">{{parentCode_name}}</view>
					</view>
					<!-- {{registInfo.orders.serviceCode}} -->
					<view class='item acea-row row-between-wrapper' style="position: relative;">
						<view class='name'><text class="requiredBox">*</text>区域服务商编号</view>
						<picker :value="registInfo.orders.serviceCodeIndex" v-model="registInfo.orders.serviceCodeIndex"
							name="rechargeWay" mode='selector' :disabled="serviceCodeEdit" :range="serviceCode_range"
							@change="serverCodeBulr" range-key='labelName'>
							<view class="uni-input pickerView" v-if="registInfo.orders.serviceCodeIndex!==null">
								{{serviceCode_range[registInfo.orders.serviceCodeIndex].labelName}}
							</view>
							<view v-else style="color:#ccc;">
								请选择区域服务商编号
							</view>
						</picker>	
						<view class="codeDetail">
							{{show_realname}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="isRegistActive==2">
			<view class='addAddress'>
				<view class='list'>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text style="color:#f00;margin-right:10rpx;">*</text>收货人姓名</view>
						<input type='text' placeholder='请输入收货人姓名' v-model="registInfo.orders.consigneeName"
							placeholder-class='placeholder'></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text style="color:#f00;margin-right:10rpx;">*</text>收货人电话</view>
						<input type='number' placeholder='请输入收货人电话' v-model="registInfo.orders.consigneeMobile"
							placeholder-class='placeholder' pattern="\d*"></input>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text style="color:#f00;margin-right:10rpx;">*</text>收货省份</view>
						<view class="address">
							<picker mode="selector" @change="bindRegionChange_province_SH" range-key="regionName"
								:range="provinceList_SH">
								<view class='acea-row'>
									<view class="picker" v-if="provinceIndex_SH==null" style="color:#ccc;">请选择收货省份
									</view>
									<view class="picker" v-if="provinceIndex_SH!==null">
										{{provinceList_SH[provinceIndex_SH].regionName}}
									</view>
									<view class='iconfont icon-dizhi font-color'></view>
								</view>
							</picker>
						</view>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text style="color:#f00;margin-right:10rpx;">*</text>收货城市</view>
						<view class="address">
							<picker mode="selector" @change="bindRegionChange_city_SH" range-key="regionName"
								:range="cityList_SH">
								<view class='acea-row'>
									<view class="picker" v-if="cityIndex_SH==null" style="color:#ccc;">请选择收货城市</view>
									<view class="picker" v-if="cityIndex_SH!==null">
										{{cityList_SH[cityIndex_SH].regionName}}
									</view>
									<view class='iconfont icon-dizhi font-color'></view>
								</view>
							</picker>
						</view>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text style="color:#f00;margin-right:10rpx;">*</text>收货区县</view>
						<view class="address">
							<picker mode="selector" @change="bindRegionChange_county_SH" range-key="regionName"
								:range="countyList_SH">
								<view class='acea-row'>
									<view class="picker" v-if="countyIndex_SH==null" style="color:#ccc;">请选择收货区县</view>
									<view class="picker" v-if="countyIndex_SH!==null">
										{{countyList_SH[countyIndex_SH].regionName}}
									</view>
									<view class='iconfont icon-dizhi font-color'></view>
								</view>
							</picker>
						</view>
					</view>
					<view class='item acea-row row-between-wrapper'>
						<view class='name'><text style="color:#f00;margin-right:10rpx;">*</text>收货地址</view>
						<input type='text' placeholder='请填写收货地址' name='dlAddress' placeholder-class='placeholder'
							v-model="registInfo.orders.consigneeAddress"></input>
					</view>
				</view>
			</view>
		</view>
		<view v-if="isRegistActive==3">
			<view class="packageInfoBox">
				<view v-for="(ele,ind) in packageInfoList" :key="ind" class="packageInfoItem">
					<view>
						<view class="packageInfoName">{{ele.PACKAGE_NAME}}</view>
						<view class="picBox">
							<image :src="ele.newImg" style="width:100%;height:100%;"></image>
							<text class="haitao">海淘</text>
						</view>
						<view class="packageInfoItemCont">
							<view>商品编号</view>
							<view>{{ele.PACKAGE_CODE}}</view>
						</view>
						<view class="packageInfoItemCont">
							<view>价格</view>
							<view>
								¥{{ele.PRICE}},
								pv:{{ele.PV}}
							</view>
						</view>
						<view class="packageInfoItemCont">
							<view>金额</view>
							<view style="position:relative">
								¥{{ele.totalNum}}
								<view class="purchaseQtyBox">
									<view class="reduce" @click="reduceFun(ele)" :class="{'non':ele.purchaseQty==0}">-
									</view>
									<view class="num">{{ele.purchaseQty}}</view>
									<view class="plus" @click="plusFun(ele)">+</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="foot acea-row row-between-wrapper" v-if="isRegistActive==3">
			<view>
				<view>总金额：¥{{packageTotalNumber}},PV:{{packageTotalPVNumber}}</view>
				<view class='keepBnt bg-color' @click="formSubmit">提交</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		checkServiceCode,
		checkMemberCode,
		h5CheckMemberCodeNull,
		h5CheckIdPasswordNull,
		checkIsFirstIntroOrder,
		getIntroducerLastLayer,
		checkRelationWhileRegister,
		getMemberByCodeCheckSameCountry,
		getRegionListByParentId,
		getPackageData,
		setRegMemberSubmit,
		getServiceCode
	} from '@/api/directSelling.js'
	import {
		IMG_URL
	} from '@/config/app_member.js';
	export default {
		data() {
			return {
				isRegistActive: 1,
				show_realname: "", //真实姓名
				introducerCode_name: "", //分享编号真实姓名
				parentCode_name: "", //服务编号名称
				isMemberCodeTrue: false, //用户名校验是否合格
				ispassworkTrue: false, //密码校验是否合格
				ismobileTrue: false, //手机号校验是否合格
				isidCardTrue: false, //证件号码校验是否正确
				releasePass: true, //判断是否可以进行下一步操作
				firstIntro: true, //判断是否为首单展示AB区最底层编号
				isFirstIntro:false,//判断服务编号是否可进行编辑操作
				registInfo: {
					member: {
						lastJoinLevel: 2, //顾客资格选择value
						lastJoinLevelIndex: 0, //顾客资格选择索引
						countryId: 1, // 会员国家ID
						memberCode: null, // 会员编号
						password: null, // 登录密码
						realName: null, // 会员姓名找国家发货中心
						mobile: null, // 会员手机号
						idCardType: 1, // 证件类型 1 身份证
						idCard: '', // 证件号码 唯一 必填
						genderIndex: null,
						gender: null, // 会员性别
						email: '', // 会员邮箱
						birthday: new Date('1995/01/01'), // 会员生日
						address: '', // 会员地址
						introducerCode: null, // 会员推荐人编号
						parentCode: '', // 会员安置人编号
						parentCodeIndex: null, //安置人编号索引
					},
					// memberBank: {},
					orders: {
						serviceCode: null, // 发货中心编号
						consigneeName: "", //收货人姓名
						consigneeMobile: "", //收货人电话
						consigneeCountryId: 1, //国家id
						consigneeProvinceId: "",
						consigneeCityId: "",
						consigneeDistrictId: "",
						consigneeAddress: "", //收货地址
						serviceCodeIndex:null,//区域服务商编号
					},
					packageInfo: [],
					orderTotalAmounts:0,
				},
				genderList: [{
						"name": "男",
						"value": "1"
					},
					{
						"name": "女",
						"value": "2"
					}
				],
				AB_last_code: [], //安置人最底层编号
				rechargeMode: [{ //是非选项
					name: "VIP- ¥1500(1200pv)",
					value: "2",
					amount: 1500,
					pv: 1200
				}, {
					name: "黄金VIP- ¥4500(3600pv)",
					value: "12",
					amount: 4500,
					pv: 3600
				}, {
					name: "钻石VIP- ¥10500(8400pv)",
					value: "22",
					amount: 10500,
					pv: 8400
				}, {
					name: "至尊VIP- ¥21000(16800pv)",
					value: "32",
					amount: 21000,
					pv: 16800
				}],
				//收货信息
				provinceList_SH: [],
				cityList_SH: [],
				countyList_SH: [],
				provinceIndex_SH: null,
				cityIndex_SH: null,
				countyIndex_SH: null,
				provinceId_SH: null,
				cityId_SH: null,
				countyId_SH: null,
				//可购商品
				MinimumAmount:0,//最低金额
				packageTotalNumber:0,
				packageTotalPVNumber:0,
				packageInfoList:[],
				isCfk: '0',
				isSelectCfk: false,
				serviceCode_range:[],
				serviceCodeEdit:false
			};
		},
		onShow() {
			console.log("onShow");
			let userInfo = uni.getStorageSync('userInfo');
			if (userInfo) {
				// if (userInfo.isService === 1) {
				// 	this.registInfo.orders.serviceCode = userInfo.memberCode;
				// 	this.h5CheckRealPlacecodeNull(this.registInfo.orders.serviceCode)
				// } else {
				// 	this.registInfo.orders.serviceCode = userInfo.serviceCode
				// 	if (userInfo.serviceCode) {
				// 		this.h5CheckRealPlacecodeNull(userInfo.serviceCode)
				// 	}
				// }
				this.getProvinceList_SH(1, 'province');
				this.getPackageList();
			}
		},
		methods: {
			registActive(ind) {
				console.log(ind);
				console.log("测试测试校验项");
				console.log(this.registInfo.orders);
				if (this.isRegistActive == 1 && ind !== 1) { //校验基本信息数据
					if (!this.isMemberCodeTrue) {
						this.$util.Tips({
							title: '登录用户名格式不正确！'
						});
						return;
					}
					if (!this.ispassworkTrue) {
						this.$util.Tips({
							title: '登录密码格式不正确！'
						});
						return;
					}
					if (!this.registInfo.member.realName) {
						this.$util.Tips({
							title: '顾客姓名不能为空'
						})
						return
					}
					if (!this.ismobileTrue) {
						this.$util.Tips({
							title: '手机号格式不正确！'
						});
						return;
					}
					if (!this.isidCardTrue) {
						this.$util.Tips({
							title: '证件号码格式不正确！'
						});
						return;
					}
					if (!this.registInfo.member.gender) {
						this.$util.Tips({
							title: '请选择性别！'
						});
						return;
					}
					if (!this.registInfo.member.introducerCode) {
						this.$util.Tips({
							title: '分享编号不能为空！'
						});
						return;
					}
					if (!this.registInfo.member.parentCode) {
						this.$util.Tips({
							title: '服务人员编号不能为空！'
						});
						return;
					}
					if (this.releasePass == false) {
						this.$util.Tips({
							title: '请检查推荐人或者安置人编号是否正确'
						})
						return;
					}
				} else if (this.isRegistActive == 2 && ind == 3) {
					if (!this.registInfo.orders.consigneeName) {
						this.$util.Tips({
							title: '请填写收货人姓名！'
						})
						return;
					}
					if (!this.registInfo.orders.consigneeMobile) {
						this.$util.Tips({
							title: '请填写收货人电话！'
						})
						return;
					}
					if (!this.provinceId_SH) {
						this.$util.Tips({
							title: '请选择收货省份！'
						})
						return;
					}
					if (!this.cityId_SH) {
						this.$util.Tips({
							title: '请选择收货城市！'
						})
						return;
					}
					if (!this.countyId_SH) {
						this.$util.Tips({
							title: '请选择收货区县！'
						})
						return;
					}
					if (!this.registInfo.orders.consigneeAddress) {
						this.$util.Tips({
							title: '请填写收货地址！'
						})
						return;
					}
				}
				this.isRegistActive = ind;
			},
			//收货省份
			bindRegionChange_province_SH(e) {
				this.provinceIndex_SH = e.detail.value;
				this.provinceId_SH = this.provinceList_SH[this.provinceIndex_SH].regionId;
				this.getProvinceList_SH(this.provinceId_SH, 'city');
			},
			bindRegionChange_city_SH(e) {
				this.cityIndex_SH = e.detail.value;
				this.cityId_SH = this.cityList_SH[this.cityIndex_SH].regionId;
				this.getProvinceList_SH(this.cityId_SH, 'county');
			},
			bindRegionChange_county_SH(e) {
				this.countyIndex_SH = e.detail.value;
				this.countyId_SH = this.countyList_SH[this.countyIndex_SH].regionId;
			},
			getProvinceList_SH(parentId, listType) {
				getRegionListByParentId({
					parentId: parentId
				}).then((res) => {
					let data = res.data;
					if (listType == 'province') { //省
						this.provinceList_SH = data;
						this.cityList_SH = [];
						this.countyList_SH = [];
						this.provinceId_SH = null;
						this.cityId_SH = null;
						this.countyId_SH = null;
						this.provinceIndex_SH = null;
						this.cityIndex_SH = null;
						this.countyIndex_SH = null;
					} else if (listType == 'city') { //市
						this.cityList_SH = data;
						this.countyList_SH = [];
						this.cityId_SH = null;
						this.countyId_SH = null;
						this.cityIndex_SH = null;
						this.countyIndex_SH = null;
					} else if (listType == 'county') { //区
						this.countyList_SH = data;
						this.countyId_SH = null;
						this.countyIndex_SH = null;
					}
				})
			},
			//获取产品列表
			getPackageList(){
				getPackageData(1).then(res=>{
					if (res.data) {
					  let data=res.data;
					  data.forEach((ele,ind)=>{
					  	ele.purchaseQty=0;
					  	ele.totalNum=0;
						ele.totalPVNum=0;
						ele.newImg=IMG_URL+'/productPackage_mall/'  + ele.ID+'/'+ ele.IMAGE_NAME
					  })
					  this.packageInfoList = data;
					  if (this.registInfo) {
					    this.registInfo.member.firstJoinLevel === -8 ? this.isCfk = '1' : this.isCfk = '0'
					    this.registInfo.member.firstJoinLevel === -8 ? this.isSelectCfk = true : this.isSelectCfk = false
					  }
					}
					
				})
			},
			reduceFun(ele){
				if(ele.purchaseQty>0){
					ele.purchaseQty=ele.purchaseQty-1;
					ele.totalNum=ele.purchaseQty*ele.PRICE;
					ele.totalPVNum=ele.purchaseQty*ele.PV;
					this.$forceUpdate();
					this.getTotalNumber();
				}
			},
			plusFun(ele){
				ele.purchaseQty=ele.purchaseQty+1;
				ele.totalNum=ele.purchaseQty*ele.PRICE;
				ele.totalPVNum=ele.purchaseQty*ele.PV;
				this.$forceUpdate();
				this.getTotalNumber();
			},
			getTotalNumber(){
				this.packageTotalNumber=0;
				this.packageTotalPVNumber=0;
				this.packageInfoList.forEach(ele=>{
					this.packageTotalNumber=this.packageTotalNumber+ele.totalNum;
					this.packageTotalPVNumber=this.packageTotalPVNumber+ele.totalPVNum;
				})
			},
			//顾客资格选择
			bindPickerChange_glzg(e) {
				this.registInfo.member.lastJoinLevelIndex = e.detail.value;
				this.registInfo.member.lastJoinLevel = this.rechargeMode[this.registInfo.member.lastJoinLevelIndex].value;
			},
			//性别选择
			bindPickerChange_gender(e) {
				this.registInfo.member.genderIndex = e.detail.value;
				this.registInfo.member.gender = this.genderList[this.registInfo.member.genderIndex].value;
			},
			//安置人编号选择
			bindPickerChange_parentCode(e) {
				this.registInfo.member.parentCodeIndex = e.detail.value;
				this.registInfo.member.parentCode = this.AB_last_code[this.registInfo.member.parentCodeIndex].value;
				this.parentCodeBlur();
			},
			//验证服务中心是否存在
			h5CheckRealPlacecodeNull(memberCode) {
				console.log('测试是否为空');
				console.log(memberCode);
				checkServiceCode(memberCode).then(res => {
					if (res.meta.success == true) {
						this.show_realname = res.data.realName
					}
				})
			},
			//判断分享编号是否存在
			introducerCodeBulr() {
				if (this.registInfo.member.introducerCode) {
					this.releasePass = false;
					this.AB_last_code=[];
					this.registInfo.member.parentCodeIndex=null;
					this.registInfo.member.parentCode="";
					this.parentCode_name="";
					this.registInfo.orders.serviceCode="";
					this.show_realname="";
					//获取区域服务商编号
					getServiceCode(this.registInfo.member.introducerCode).then(res=>{
						//this.registInfo.orders.serviceCode=res.data;
						this.registInfo.orders.serviceCodeIndex=null;
						this.serviceCode_range=[]
						this.serviceCodeEdit=false;
						if(res.data){
							res.data.forEach((ele,ind)=>{
								ele.labelName=ele.memberCode+"-"+ele.realName
							})
							this.serviceCode_range=res.data;
							if(res.data.length==1){
								this.registInfo.orders.serviceCodeIndex=0;
								this.serviceCodeEdit=true;
								this.registInfo.orders.serviceCode=this.serviceCode_range[0].memberCode;
								this.h5CheckRealPlacecodeNull(this.registInfo.orders.serviceCode)
							}
						}
					})
					
					checkMemberCode(this.registInfo.member.introducerCode).then(res => {
						if (res.meta.success) {
							this.releasePass = true;
							this.introducerCode_name = res.data.realName;
							this.getIsThereAnyone(this.registInfo.member.introducerCode);
						}
					})
				}

			},
			//判断是否存在最底层编号推首单
			getIsThereAnyone(code) {
				checkIsFirstIntroOrder(code).then(res => {
					if (res.data.memberCode !== null) {
						this.registInfo.member.parentCode = res.data.memberCode
						this.firstIntro = true
						this.isFirstIntro=false
					} else {
						this.firstIntro = false;
						this.isFirstIntro=false
						this.getIntroducerLastLayer(code)
					}
				})
			},
			//推荐人的两个人安置人ab区下最后一层左边编号
			getIntroducerLastLayer(code) {
				getIntroducerLastLayer(code).then(res => {
					if (res.data.A) {
						this.AB_last_code.push({
							label: 'A区: ' + res.data.A.memberCode,
							value: res.data.A.memberCode
						})
					}
					if (res.data.B) {
						this.AB_last_code.push({
							label: 'B区: ' + res.data.B.memberCode,
							value: res.data.B.memberCode
						})
					}
					this.firstIntro = false
					this.isFirstIntro=false
				})
			},
			//登录用户名变更校验
			memberCodeBlur() {
				this.isMemberCodeTrue = false;
				if (this.registInfo.member.memberCode) {
					h5CheckMemberCodeNull(this.registInfo.member.memberCode).then(res => {
						if (res.meta.success == true) {
							this.isMemberCodeTrue = true;
						}
					})
				}
			},
			//登录密码校验是否合格
			passwordBlur() {
				this.ispassworkTrue = false;
				if(this.registInfo.member.password){
					h5CheckIdPasswordNull(this.registInfo.member.password).then(res => {
						if (res.meta.success == true) {
							this.ispassworkTrue = true;
						}
					})
				}
			},
			//验证手机号格式
			mobileBlur() {
				this.ismobileTrue = false;
				if (!this.registInfo.member.mobile) return this.$util.Tips({
					title: '请填写手机号'
				});
				if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.registInfo.member.mobile)) return this.$util.Tips({
					title: '手机号格式错误'
				});
				this.ismobileTrue = true;
			},
			//验证证件号码是否合格且注册会员年龄大于18周岁
			idCardBlur() {
				console.log("提交");
				if (!this.checkIDCard(this.registInfo.member.idCard)) {
					this.$util.Tips({
						title: '身份证格式错误'
					});
					this.isidCardTrue = false;
					return false
				}else {
					var str2 = this.registInfo.member.idCard;
					var year = str2.slice(6, 10);
					var month = str2.slice(10, 12);
					var date = str2.slice(12, 14);
					let bir=`${year}-${month}-${date}`;
					let nowYear=new Date().getFullYear();
					let nowMonth=new Date().getMonth() + 1;
					let nowDate=new Date().getDate();
					if(nowMonth<10){
						nowMonth="0"+nowMonth;
					}
					if(nowDate<10){
						nowDate="0"+nowDate;
					}
					this.isidCardTrue = false;
					if(nowYear-year>18){
						this.isidCardTrue = true;
						this.registInfo.member.birthday=bir;
					}else if(nowYear-year==18){
						//  13112220040109342X
						if(nowMonth<month){
							this.$util.Tips({
								title: '注册会员年龄须大于18岁'
							});
						}else{
							if(nowMonth=month){
								if(nowDate<date){
									this.$util.Tips({
										title: '注册会员年龄须大于18岁'
									});
								}else{
									this.isidCardTrue=true;
								}
							}else{
								this.isidCardTrue=true;
							}
						}
					}else{
						this.$util.Tips({
							title: '注册会员年龄须大于18岁'
						});
					}
				}
			},
			checkIDCard(idcode) {
				// 加权因子
				var weight_factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
				// 校验码
				var check_code = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']

				var code = idcode + ''
				var last = idcode[17] // 最后一位

				var seventeen = code.substring(0, 17)

				// ISO 7064:1983.MOD 11-2
				// 判断最后一位校验码是否正确
				var arr = seventeen.split('')
				var len = arr.length
				var num = 0
				for (var i = 0; i < len; i++) {
					num = num + arr[i] * weight_factor[i]
				}

				// 获取余数
				var resisue = num % 11
				var last_no = check_code[resisue]

				// 格式的正则
				// 正则思路
				var idcard_patter =
					/^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/

				// 判断格式是否正确
				var format = idcard_patter.test(idcode)
				console.log('last');
				console.log(last)
				console.log("last_no");
				console.log(last_no)
				// 返回验证结果，校验码和格式同时正确才算是合法的身份证号码
				return !!(last === last_no && format)
			}, 
			//区域服务商编号变更方法
			serverCodeBulr(e) {
				this.registInfo.orders.serviceCodeIndex=e.detail.value;
				this.registInfo.orders.serviceCode=this.serviceCode_range[this.registInfo.orders.serviceCodeIndex].memberCode;
				this.h5CheckRealPlacecodeNull(this.registInfo.orders.serviceCode)
			},
			//获取服务编号对应名称
			parentCodeBlur() {
				if (this.registInfo.member.parentCode) {
					this.releasePass = false;
					this.isFirstIntro=true;
					this.checkParentPlace(this.registInfo.member.parentCode);
					this.yan_parentCode_name(this.registInfo.member.parentCode);
				}
			},
			checkParentPlace(code) {
				checkRelationWhileRegister(code).then(res => {

				})
			},
			yan_parentCode_name(code) {
				const memberCode = code;
				if (this.recInfo) {
					getMemberByCodeCheckSameCountry(memberCode).then(res => {
						if (res.meta.success) {
							this.releasePass = true;
							this.parentCode_name = res.data.realName;
						} else {
							this.releasePass = false;
						}
					})
				} else {
					checkMemberCode(memberCode).then(res => {
						if (res.meta.success) {
							this.releasePass = true;
							this.parentCode_name = res.data.realName;
						} else {
							this.releasePass = false;
						}
					})
				}
			},
			/**
			 * 提交用户添加地址
			 * 
			 */
			formSubmit: function(e) {
				console.log("registInfo");
				console.log(this.registInfo);
				if (!this.provinceId_SH) {
					this.$util.Tips({
						title: '请选择收货省份！'
					})
					return;
				}
				if (!this.cityId_SH) {
					this.$util.Tips({
						title: '请选择收货城市！'
					})
					return;
				}
				if (!this.countyId_SH) {
					this.$util.Tips({
						title: '请选择收货区县！'
					})
					return;
				}
				this.registInfo.orders.consigneeProvinceId=this.provinceId_SH;//收货省份
				this.registInfo.orders.consigneeCityId=this.cityId_SH;//收货城市
				this.registInfo.orders.consigneeDistrictId=this.countyId_SH;//收货区县
				this.registInfo.orderTotalAmounts=this.packageTotalNumber;//选购总金额
				this.registInfo.member.province=this.provinceId_SH;
				this.registInfo.member.city=this.cityId_SH;
				this.registInfo.member.district=this.countyId_SH;
				this.registInfo.member.countryId=1;
				let packageInfo=[];
				if(this.registInfo.orderTotalAmounts==0){
					this.$util.Tips({
						title: '订单金额不能为0！'
					})
					return;
				}else{
					this.packageInfoList.forEach((ele,ind)=>{
						if(ele.purchaseQty>0){
							packageInfo.push({
								packageId: ele.ID,
								purchaseQty: ele.purchaseQty
							})
						}
					})
					this.registInfo.packageInfo=packageInfo;
				}
				setRegMemberSubmit(this.registInfo).then(res=>{
					let data=res.data;
					if(data){
						uni.navigateTo({
							url: '/pages/users/order_confirm/orderDetails?orderId=' + data +
								"&saleType=1" 
						})
					}
				})
			},

		}
	}
</script>

<style scoped lang="scss">
	body,
	page {
		background: #fff;
	}

	.addAddress .list {
		background-color: #fff;
	}

	.addAddress .list .item {
		padding: 30rpx;
		border-bottom: 1rpx solid #eee;
	}

	.addAddress .list .item .name {
		width: 195rpx;
		font-size: 30rpx;
		color: #333;
	}

	.addAddress .list .item .address {
		// width: 412rpx;
		flex: 1;
		margin-left: 20rpx;
		position: relative;
	}

	.addAddress .list .item input {
		width: 475rpx;
		font-size: 30rpx;
	}

	.addAddress .list .item .placeholder {
		color: #ccc;
	}

	.addAddress .list .item picker {
		width: 475rpx;
		height: 42rpx;
	}

	.addAddress .list .item picker .picker {
		width: 410rpx;
		font-size: 24rpx;
	}

	.addAddress .list .item picker .iconfont {
		font-size: 43rpx;
	}

	.addAddress .default {
		padding: 0 30rpx;
		height: 90rpx;
		background-color: #fff;
		margin-top: 23rpx;
	}

	.addAddress .default checkbox {
		margin-right: 15rpx;
	}

	.addAddress .keepBnt {
		width: 690rpx;
		height: 86rpx;
		border-radius: 50rpx;
		text-align: center;
		line-height: 86rpx;
		margin: 50rpx auto;
		font-size: 32rpx;
		color: #fff;
	}

	.addAddress .wechatAddress {
		width: 690rpx;
		height: 86rpx;
		border-radius: 50rpx;
		text-align: center;
		line-height: 86rpx;
		margin: 0 auto;
		font-size: 32rpx;
		color: #fe960f;
		border: 1px solid #fe960f;
	}

	.requiredBox {
		color: #f00;
		margin-right: 7rpx;
	}

	.registerTitle {
		display: flex;
		background: #fff;
		border-bottom: 1px solid #ccc;

		>view {
			flex: 1;
			text-align: center;
			height: 100rpx;
			line-height: 100rpx;
		}

		>view.active {
			background: $theme-color;
			color: #fff;
		}
	}

	.codeDetail {
		position: absolute;
		top: 50%;
		right: 50rpx;
		transform: translateY(-50%);
		font-weight: bold;
		font-size: 30rpx;
		color: $theme-color;
	}

	.uni-input-placeholder {
		font-size: 25rpx !important;
	}

	.packageInfoBox {
		.MinimumAmountBox {
			background: #fff;
			font-size: 26rpx;
			padding: 30rpx 30rpx 0 30rpx;
			box-sizing: border-box;
		}

		.packageInfoItem {
			width: 100%;
			height: auto;
			background: #fff;
			margin-bottom: 100rpx;
			padding: 0 40rpx 20rpx 40rpx;
			box-sizing: border-box;
			font-size: 28rpx;
			border-bottom: 1px solid #eee;
			.picBox{
				width:200rpx;
				height:200rpx;
				position:relative;
				border-radius: 20rpx;
				margin:20rpx 0;
			}
			.packageInfoName {
				color: #000;
				font-size: 30rpx;
				line-height: 100rpx;
				font-weight: 500;
			}

			.packageInfoItemCont {
				line-height: 80rpx;

				>view {
					display: inline-block;
					vertical-align: middle;
				}

				>view:nth-child(1) {
					width: 200rpx;
				}

				>view:nth-child(2) {
					width: calc(100% - 200rpx);
					font-size: 30rpx;

					.purchaseQtyBox {
						position: absolute;
						right: 10rpx;
						top: 0;

						>view {
							display: inline-block;
							vertical-align: middle;
						}

						>view.reduce {
							border: 1rpx solid #a4a4a4;
							width: 66rpx;
							height: 42rpx;
							line-height: 36rpx;
							text-align: center;
						}

						>view.num {
							border: 1rpx solid #a4a4a4;
							width: 66rpx;
							height: 42rpx;
							line-height: 36rpx;
							text-align: center;
							margin: 0 1rpx;
						}

						>view.plus {
							border: 1rpx solid #a4a4a4;
							width: 66rpx;
							height: 42rpx;
							line-height: 36rpx;
							text-align: center;
						}

						>view.non {
							border: 1rpx solid #e3e3e3;
							color: #dedede;
						}
					}
				}
			}
		}
	}
	.foot {
		position: fixed;
		width: 100%;
		background-color: #fff;
		bottom: 0;
		height: 116rpx;
		border-top:1px solid #eee;
		z-index:12;
		>view{
			width:100%;
			display:flex;
			align-items: center;
			justify-content: space-between;
			padding:0 20rpx;
			box-sizing: border-box;
		}
		.keepBnt {
			width: 200rpx;
			height: 66rpx;
			border-radius: 50rpx;
			text-align: center;
			line-height: 66rpx;
			font-size: 32rpx;
			color: #fff;
		}
	}
	.haitao{
		display:inline-block;
		vertical-align: middle;
		width:55rpx;
		height:55rpx;
		border-radius: 50%;
		background:#f00;
		color:#fff;
		font-size:24rpx;
		line-height:55rpx;
		text-align:center;
		position:absolute;
		right:-30rpx;
		top:-30rpx;
		z-index: 11;
	}
</style>
